<?php

namespace Biz\service\activity;


class SearchFeedback
{

    public static $score = [
        [
            "id" => 1,
            "title" => "非常不满意",
        ],
        [
            "id" => 2,
            "title" => "不满意",
        ],
        [
            "id" => 3,
            "title" => "一般",
        ],
        [
            "id" => 4,
            "title" => "满意",
        ],
        [
            "id" => 5,
            "title" => "非常满意",
        ],
    ];

    public static $reason = [
        [
            "id" => 1,
            "title" => "内容单一，不够丰富",
        ],
        [
            "id" => 2,
            "title" => "无关内容多",
        ],
        [
            "id" => 3,
            "title" => "疑似广告内容多",
        ],
        [
            "id" => 4,
            "title" => "搬运抄袭内容多",
        ],
    ];

    /**
     * 插入 record 数据
     * @param int pageId
     * @param int moduleId
     * @param string name
     * @param string phone
     * @param string area
     * @param int is_save
     * @param int active_uid
     * @return bool result
     *
     * @throws \Exception
     */
    public static function addSearchFeedBack($uid, $feedback_score, $feedback_reason, $feedback_other, $input_requestId, $input_query)
    {
        //分数和搜索结果反馈为必须
        if (empty($feedback_score) || empty($feedback_reason)) throw new \Exception('满意度和搜选结果存在的问题必选');
        //检查是否是同一次搜索提交
        $msg = "反馈已收到，不用重复提交啦～";
        if ($uid && \Biz\model\activity\SearchFeedback::findFeedback($uid, $input_requestId, $input_query)) throw new \Exception($msg);

        \Biz\model\activity\SearchFeedback::addFeedback($uid, $feedback_score, $feedback_reason, $feedback_other, $input_requestId, $input_query);
    }

    public static function admList($page, $pageSize)
    {
        $offset = ($page - 1) * $pageSize;
        $offset = $offset > 0 ? $offset : 0;
        $where = [
            'ORDER' => [
                'id' => 'DESC',
            ],
            'LIMIT' => [
                $offset,
                $pageSize
            ]
        ];
        $list = \Biz\model\activity\SearchFeedback::getListByWhere($where);


        return $list;
    }


}